package com.manager.cms.common;

import lombok.Data;

import java.io.Serializable;

/**
 */
@Data
public class CommonResponse implements Serializable {

    private static final long serialVersionUID = 1725159680599612404L;

    private static final String CODE_SUCCESS = "200";
    private static final String CODE_FAILURE = "500";

    /**
     * 结果
     */
    private String code;

    /**
     * 数据
     */
    private Object data;

    public static CommonResponse succeed() {
        CommonResponse response = new CommonResponse();
        response.setCode(CODE_SUCCESS);
        return response;
    }

    public static CommonResponse succeed(Object data) {
        CommonResponse response = new CommonResponse();
        response.setCode(CODE_SUCCESS);
        response.setData(data);
        return response;
    }

    public static CommonResponse succeed(String code, Object data) {
        CommonResponse response = new CommonResponse();
        response.setCode(code);
        response.setData(data);
        return response;
    }

    public static CommonResponse fail() {
        CommonResponse response = new CommonResponse();
        response.setCode(CODE_FAILURE);
        return response;
    }

    public static CommonResponse fail(Object data) {
        CommonResponse response = new CommonResponse();
        response.setCode(CODE_FAILURE);
        response.setData(data);
        return response;
    }

    public static CommonResponse fail(String code, Object data) {
        CommonResponse response = new CommonResponse();
        response.setCode(code);
        response.setData(data);
        return response;
    }
}
